<?php echo $header; ?>

<div id="container" class="clearfix">
    <div class="w-content clearfix">
        <?php echo $category ?>

        <div class="col-right clearfix">
            <div class="text-content prod-page-2 brands-detail">
                <div class="wrap-top clearfix">
                    <ul class="breakcum">
                        <?php foreach ($breadcrumbs as $breadcrumb) { ?>
                            <?php if($breadcrumb['href']) { ?>
                                <li><a href="<?php echo $breadcrumb['href']; ?>" title="<?php echo $breadcrumb['text']; ?>"><?php echo $breadcrumb['text']; ?> </a></li>
                            <?php }else { ?>
                                <li><a href="javascript:void(0);" title="<?php echo $breadcrumb['text']; ?>"><?php echo $breadcrumb['text']; ?> </a></li>
                            <?php } ?>
                        <?php } ?>
                    </ul>
                    <div class="sortPro">
                        <span><?php echo $text_sort; ?></span>
                        <select class="sort_products-1" name="sort" onchange="location = this.value">
                            <?php foreach ($sorts as $sort_item) { ?>
                                <?php if (($sort . '-' . $order) == $sort_item['value']) { ?>
                                    <option value="<?php echo $sort_item['href']; ?>" selected="selected"><?php echo $sort_item['text']; ?></option>
                                <?php } else { ?>
                                    <option value="<?php echo $sort_item['href']; ?>"><?php echo $sort_item['text']; ?></option>
                                <?php } ?>
                            <?php }?>
                        </select>
                    </div>
                </div><!--wrap-top-->

                <div class="wrapimgbrands"><img src="<?php echo $logo ?>" alt="<?php echo $heading_title; ?>"/></div>
                <h4 class="box_tt"><?php echo $heading_title; ?></h4>
                <div><?php echo $description ?></div>
            </div>
            <!--text-content-->

            <div id="product_list" class="wrap-list-prod">
                <ul id="product_loaded<?php echo $lazy_load['page'] ?>" class="listProd">
                    <?php $i = 0; ?>
                    <?php foreach ($products as $product) { ?>
                        <li>
                            <a href="#" class="product">
                                <?php if($product['discount']){ ?>
                                    <div class="sale-off"><span>-<?php echo $product['rate_discount'];?></span><span>%</span></div>
                                <?php } ?>
                                <?php $href = str_replace('&', '&amp;', $product['href']); ?>
                                <a class="prod-img" href="<?php echo $href; ?>"><img src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>">
                                    <?php if($product['options']) { ?>
                                        <div class="product_sizes_popup">
                                            <?php $op = 0; ?>
                                            <?php foreach($product['options'] as $options){ ?>
                                                <?php
                                                $option_data = '';
                                                foreach($options['option_value'] as $option_item){
                                                    $option_data .=  $option_item['name'] . ', ';
                                                }
                                                $option_data = trim($option_data, ', ');
                                                ?>

                                                <p class="header <?php echo ($op > 0 ? ' p5t' : ''); ?>"><?php echo (strcasecmp($options['name'], 'Størrelse') == 0) ? 'Størrelser' : $options['name'] ?></p>
                                                <p class="data"><?php echo $option_data ?></p>
                                                <?php $op++; ?>
                                            <?php } ?>
                                        </div>
                                    <?php } ?>
                                </a>
                                <div class="prod-name"><p><?php echo $product['name']; ?> </p></div>
                                <div class="prod-price">
                                    <?php if($product['discount']){ ?>
                                        <span class="price-old"> <?php echo $product['price']; ?></span><span class="price-new"><?php echo $product['discount']; ?></span>
                                    <?php }else{ ?>
                                        <span class="price-normal"><?php echo $product['price']; ?></span>
                                    <?php } ?>
                                </div>
                                <a href="<?php echo $href; ?>" class="btn btnBestil">Bestil Nu</a>
                                <div class="see-inc"><a class="hastool" title="<?php echo $shipping_note; ?>">Se pris inkl. fragt/gebyr</a></div>
                            </a>
                         </li>

                        <?php $i++; ?>
                    <?php } ?>
                </ul>

                <div id="lazy_loading" class="lazy_loading">
                    <a id="load_next_page" href="#">
                        <span>Se flere produkter</span>
                        <img src="catalog/view/theme/<?php echo $template; ?>/images/lazyload14.gif"/>
                    </a>
                </div>
            </div>
            <!--wrap-list-prod-->
        </div>
        <!--col-right -->
    </div>
    <!--w-content-->

    <!--wrap-list-serviecs-->
    <?php echo $services ?>

    <?php echo $newsletter ?>
</div>
<!--#container-->

<script type="text/javascript">
    var page = <?php echo $lazy_load['page'] ?>;
    var limit = <?php echo $lazy_load['limit'] ?>;
    var total = <?php echo $lazy_load['total'] ?>;
    var url = '<?php echo $lazy_load['url']?>&lazy_load=1';

    $(window).scroll(function() {
        var pos = $(window).scrollTop();
        var windowHeight = $(window).height();
        var footer = Math.round($('#footer').offset().top);
        var loadingId = '#lazy_loading';


        $(loadingId).hide();
        if((pos + windowHeight > footer - 100) && ((page) * limit < total)){
            $(loadingId).show();
        }
    });

    $('#load_next_page').on('click', function(e){
        e.preventDefault();

        var data = {
            "page":             page,
            "limit":            limit,
            "total":            total,
            "url":              url,

            "loading_id":       'lazy_loading',
            "result_id":        'product_list ul:last'
        }

        page = lazyLoad(data);
    })
</script>

<?php echo $footer; ?> 

